' Test ag First String Functions.txt b+ 2021-02-23& 24 reworked var functionName arg1, arg2,...

. To assign a var:
. var = literal (number or string) or SFunction with name then Square brackets.
. !!! Note: all Square Brackets have been replaced by here {} Brackets in code use Square Brackets !!!
. Introducing: First String Functions Case Insensitive !!! put all literals right next to comma !!!
. HEAD  Syntax: var = Head{source$,sec$}        eg var = head{hello world,ll} > var = he
. TAIL  Syntax: var = Tail{source$,sec$}        eg var = tail{hello world,ll} > var = o world
. MID1  Syntax: var = Mid1{source$,charPos#}    eg var = mid1{hello world,5}  > var = o
. MID2  Syntax: var = Mid2{source$,startPos#}   eg var = Mid2{hello world,7}  > var = world
. MID3  Syntax: var = mid3{s$,start#, len#}     eg var = mid3{hello,2,3}      > var = el 
. IN2   Syntax: var = in2{s$,match$}            eg var = in2{hello,l}         > var = 3
. IN3   Syntax: var = in3{start#,s$,match$}     eg var = in3{6,hello world,l} > var = 10 
. CAP   syntax: var = cap{s$}                   eg var = cap{shout!}          > var = SHOUT!
. LOW   syntax: var = low{s$}                   eg var = low{Whipser}         > var = whisper
. BND   syntax: var = bnd{a1,a2,a3..}           eg var = bnd{a1,a2,a3,...}    > var = a1a2a3...
' Best to trim because picking up a space occasionally
hw = trim[Hello World!]
char_H = trim[H]
char_W = trim[W]
. Did it take? show how hw was set in code: 
' dot in next line should prevent activating "", it does.
. hw = Hello World!
' test the " method of variable assignment
. And hw has the value: ;hw;/ and char_H: ;char_H;/ and char_W: ;char_W
hwLen = len[hw]
. And hw has the len of: ;hwLen
.
. Here we try String Functions: head, tail, mid3, mid1, (behind scenes) CHR, SPC
sp1 = chr[32]
'sp1 = spc[1]
hspace = head[hw,sp1]
tspace = tail[hw,sp1]
low = Mid3[hw,4,4]
first = Mid1[hw,1]
' actually if the literal is numeric and positive you can have a space after comma.
seventh = mid1[hw,7] 
. /         Head from space = *;hspace;*
. /      Tail from space = *;tspace;*
. / mid3 from 4, 4 chars = *;low;*
. / What's at the first (first = mid1{hw,1}) and seventh positions? answer: ;first;/ and ;seventh
.
find_lh = in2[hw,h]
find_UH = in2[hw,char_H]
find_W = in2[hw,char_W]
. / In2 has 2 arguments: SearchInThisString, andTheItemToMatch
. / In3 has 3 arguments: startPlaceOfSearch, the StringToSearch, theItemToFind. 
.   Instr2 Tests:
. Any h's in ;hw;? Answer: ;find_lh
. Any H's in ;hw;? Answer: ;find_UH
. Any W's in ;hw;? Answer: ;find_W
. The original variable hw was derived from 1st letters at (find H) ;find_uH; and at (find W) ;find_W;.
. /     What the L? find all the places it's located, using Instr2, Instr3
.   In3 Test:
place = in2[hw,l]
[
	If place
		cnt = a[cnt,1]
		.  #;cnt; l resides at ;place;# in ;hw;.
		place = In3[a[place,1],hw,l]
	El
		. /      That's all the L, we found.
		Exit
	Fi	
]
. /     Testing Spc n  for spaces and & arg1,arg2,arg3... concatenate with &
[
	n = a[n,1]
	space = spc[n]
	bind = bnd[hw,space]
	; bind
	chars = a[chars,hwLen,n]
	jmp gt[a[chars,hwlen,n,1],128]
]
. 
. Goodnight!
Zzz